]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
swipeTracker: Handle invalid position when finding previous point
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 4 Feb 2026 13:12:25 +0000 (14:12 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 4 Feb 2026 16:28:12 +0000 (17:28 +0100)
Commit 8e29babca8adc677 switched to `findLastIndex()` to find
the previous point, which inadvertently changed what value is
returned for invalid input.

Restore the old fallback value and log a stacktrace, so we can
hopefully track down what causes the invalid input.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8856
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4062>

js/ui/swipeTracker.js

index c21d51e658b229a7a8f0462958e489d5c1d30233..05b5b2cc6c28b5b10fd7043ff32f3bb442252075 100644 (file)
@@ -523,7 +523,14 @@ export const SwipeTracker = GObject.registerClass({
     }
 
     _findPreviousPoint(pos) {
-        return this._snapPoints.findLastIndex(p => p <= pos);
+        const index =
+            this._snapPoints.findLastIndex(p => p <= pos);
+        if (index !== -1)
+            return index;
+
+        console.trace(`Invalid position ${pos}`);
+        // also out-of-bounds, but somehow callers fail less hard than with -1
+        return this._snapPoints.length;
     }
 
     _findPointForProjection(pos, velocity) {